@echo off

if not exist ..\import\dother\*.txt  goto noDotherImport

if not exist importdec  mkdir  importdec
if not exist import  mkdir  import


if not exist extdec\*.mt   call  wiso\eMt.bat

FOR %%i IN (..\import\dother\*.txt) DO (
    if exist extdec\%%~ni.mt   ffxmt -i    -t ffx.tbs  extdec\%%~ni.mt   %%i   importdec\%%~ni.mt
)
rem for those bigger than max space, or problematic (size somewhere else?) use 'packing'
FOR %%i IN (1093) DO (
    if exist ..\import\dother\%%i.txt  if exist extdec\%%~ni.mt   ffxmt -i -x -t ffx.tbs  extdec\%%~ni.mt   ..\import\dother\%%i.txt   importdec\%%~ni.mt
)



if not exist extracted\*.dlg   call  wiso\eOther.bat

FOR %%i IN (..\import\dother\*.txt) DO (
    if exist extracted\%%~ni.dlg   ffxdlg -i  -t ffx.tbs  extracted\%%~ni.dlg   %%i   import\%%~ni.dlg
)



if not exist extdec\*.dlg2   call  wiso\eOther.bat

FOR %%i IN (..\import\dother\*.txt) DO (
    rem for 0219 not setting out file extension to dlg2 due next processing
    if exist extdec\%%~ni.dlg2   ffxdlg2 -i  -t ffx.tbs  extdec\%%~ni.dlg2   %%i   importdec\%%~ni
)

rem join .dlg2 to .pd2
if exist importdec\0219.0??  (
    rem copy those which dont exist without extension
    FOR %%i IN (extdec\0219.0??.dlg2) do ( if not exist importdec\%%~ni  copy   %%i  importdec\%%~ni >NUL )
    shsplit.exe  4  -i extracted\0219.pd2  -f  -hmax 0x40  -min 0x40 -ebm 16  importdec\0219   import\0219.pd2
)



if not exist extdec\*.mt2      call  wiso\eMt2.bat

rem no specific program yet
rem import part with texts, inport size is limited
if exist ..\import\dother\0174.txt (
    fcopy.exe -ep  extdec\0174.mt2  temp.tmp    0x0  0xADFD
    shsplit.exe  4  -i temp.tmp  -df delim.txt  -t ffx.tbs   -hb 0x114  -e 0xAE00   ..\import\dother\0174.txt  temp2.tmp
    copy /Y extdec\0174.mt2  importdec\0174.mt2  >NUL
    fcopy.exe -IP  importdec\0174.mt2   temp2.tmp    0x0  0xAE00
)
if exist ..\import\dother\0177.txt (
    fcopy.exe -ep  extdec\0177.mt2  temp.tmp    0x0  0x13B81
    shsplit.exe  4  -i temp.tmp  -df delim.txt  -t ffx.tbs   -hb 0x384  -e 0x13B90  ..\import\dother\0177.txt  temp2.tmp
    copy /Y extdec\0177.mt2  importdec\0177.mt2  >NUL
    fcopy.exe -IP  importdec\0177.mt2  temp2.tmp    0x0  0x13B90
)
if exist ..\import\dother\0180.txt (
    fcopy.exe -ep  extdec\0180.mt2  temp.tmp    0x0  0x29F4
    shsplit.exe  4  -i temp.tmp  -df delim.txt  -t ffx.tbs   -hb 0x114  -e 0x2A00   ..\import\dother\0180.txt  temp2.tmp 
    copy /Y extdec\0180.mt2  importdec\0180.mt2  >NUL
    fcopy.exe -IP  importdec\0180.mt2  temp2.tmp    0x0  0x2A00
)



:noDotherImport

